﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour
{
    public Vector3 speed;

    public Vector2 rotate;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void LateUpdate()
    {
        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");
        float y = Input.GetKey(KeyCode.Space) ? 1 : 0;
        Vector3 s = new Vector3(speed.x * x, speed.y * y, speed.z * z);
        transform.Translate(s * Time.deltaTime);

        float rotateY = Input.GetAxis("Mouse X") * rotate.y;
        float rotateX = -Input.GetAxis("Mouse Y") * rotate.x;
        Vector3 eulers = new Vector3(rotateX, rotateY, 0) + transform.eulerAngles;
        transform.rotation = Quaternion.Euler(eulers);
    }
}
